unit Tile;

interface

uses Engine, DGLE, DGLE_Types;

type
  TTile = array [0..TILES_COUNT - 1] of ITexture;

const
  TileFName: array [0..TILES_COUNT - 1] of AnsiString = (
  'Dirt.png'
  );

type
  TTiles = class
  private
    pTile: TTile;
  public
    constructor Create;
    destructor Destroy; override;
    procedure Render(X, Y, ID: Integer);
  end;

implementation

{ TTiles }

constructor TTiles.Create;
var
  I: Byte;
begin
  for I := 0 to TILES_COUNT - 1 do
  begin
    pTile[I] := nil;
    pResMan.Load(PAnsiChar('Resources\Sprites\Tiles\' + TileFName[I]),
      IEngineBaseObject(pTile[I]), TEXTURE_LOAD_DEFAULT_2D);
  end;
end;

destructor TTiles.Destroy;
var
  I: Byte;
begin
  for I := 0 to TILES_COUNT - 1 do pTile[I] := nil;
  inherited;
end;

procedure TTiles.Render(X, Y, ID: Integer);
begin
  pRender2D.DrawTexture(pTile[ID], Point2(X * TILE_SIZE + SCR_LEFT,
    Y * TILE_SIZE + SCR_TOP), Point2(TILE_SIZE, TILE_SIZE));
end;

end.
